package com.base;

/**
 * 消息模板类型枚举
 */
public enum MessageTypeEnum {
    
    /**
     * 创建工单通知
     */
    CREATE_WORK_ORDER("CREATE_WORK_ORDER", "创建工单通知"),
    
    /**
     * 工单派工通知
     */
    WORK_ORDER_ASSIGNMENT("WORK_ORDER_ASSIGNMENT", "工单派工通知"),
    
    /**
     * 业务审核通知
     */
    BUSINESS_REVIEW("BUSINESS_REVIEW", "业务审核通知"),
    
    /**
     * 审核拒绝通知
     */
    REVIEW_REJECT("REVIEW_REJECT", "审核拒绝通知"),
    
    /**
     * 任务完成通知
     */
    TASK_COMPLETE("TASK_COMPLETE", "任务完成通知"),
    
    /**
     * 问题反馈通知
     */
    PROBLEM_FEEDBACK("PROBLEM_FEEDBACK", "问题反馈通知");
    
    private final String code;
    private final String description;
    
    MessageTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据code获取枚举
     */
    public static MessageTypeEnum fromCode(String code) {
        for (MessageTypeEnum type : MessageTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
    
    /**
     * 判断code是否存在
     */
    public static boolean exists(String code) {
        return fromCode(code) != null;
    }
}